﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace DroughtAnalysis
{
    /// <summary>
    /// Manages the current available drought methods
    /// </summary>
    public class DroughtMethodManager
    {
        /// <summary>
        /// Gets the drought methods from the current directory
        /// </summary>
        /// <returns>The list of all drought methods found in the directory</returns>
        public IEnumerable<DroughtMethodInfo> GetDroughtMethodsFromDirectory()
        {
            string dir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            string[] rFiles = Directory.GetFiles(dir, "*.r");

            List<DroughtMethodInfo> validRFiles = new List<DroughtMethodInfo>();

            foreach(string rFile in rFiles)
            {
                DroughtMethodInfo methodInfo = DroughtMethodInfo.FromRScript(rFile);
                if (methodInfo.IsValidMethod())
                {
                    validRFiles.Add(methodInfo);
                }
            }
            return validRFiles;
        }

        /// <summary>
        /// Gets the drought methods from the user-defined settings (Settings.Settings)
        /// </summary>
        /// <returns>The list of all drought methods from the user settings</returns>
        public IList<DroughtMethodInfo> GetDroughtMethodsFromSettings()
        {
            throw new NotImplementedException();
        }
    }
}
